/**
 * 场景管理类
 */
class SceneManager {
    /* 设置所有场景所在的舞台(根)*/
    private _stage: egret.DisplayObjectContainer;
    /**场景列表 */
    public sceneItem: any[] = [];
    /**构造 */
    constructor() {
    }
    /**实例 */
    static sceneManager: SceneManager;
    /**获取实例对象 */
    static get instance() {
        if (!this.sceneManager) {
            this.sceneManager = new SceneManager()
        }
        return this.sceneManager
    }
    /**
     * 设置根场景
     * @param s 根场景
     */
    public setStage(s: egret.DisplayObjectContainer) {
        this._stage = s
    }

    /** 删除其他场景*/
    public removeOther() {
        for (let i = 0; i < this.sceneItem.length; i++) {
            if (this.sceneItem[i].parent) {
                this._stage.removeChild(this.sceneItem[i]);
                this.sceneItem[i] = null;
                this.sceneItem.splice(i, 1);
            }
        }
    }
    /**切换场景 */
    public SitchScene(sceneName: SceneName) {
        this.removeOther();
        /**场景临时变量 */
        let scene;
        switch (sceneName) {
            case SceneName.登录场景:
                scene = new LoginMain();
                break;
            case SceneName.新手引导:
                scene = new xinshou();
                break;
            case SceneName.单机场景:
                scene = new singleGame();
                break;
            case SceneName.联网场景:
                scene = new multGame();
                break;
            default:
                break;
        }
        if (scene) {
            this.sceneItem.push(scene);
            this._stage.addChild(scene);
        }
    }
}
enum SceneName {
    登录场景, 单机场景, 联网场景, 新手引导
}